package com.hong.qrpc.factory;

import com.hong.config.constant.ClientConfig;
import com.hong.qrpc.strategy.PropertiesStrategy;
import com.hong.qrpc.strategy.client.config.CodeClassStrategy;
import com.hong.qrpc.strategy.client.config.PortStrategy;
import com.hong.qrpc.strategy.client.config.ProtoTypeStrategy;
import com.hong.qrpc.strategy.client.config.TransportClassStrategy;
import com.hong.qrpc.strategy.invoker.config.LoadBalanceModeStrategy;
import com.hong.qrpc.strategy.invoker.config.RetryStrategy;
import com.hong.qrpc.strategy.invoker.config.TimeoutStrategy;
import com.hong.qrpc.strategy.register.DiscoverServiceAddrStrategy;
import com.hong.qrpc.strategy.register.RegisterTypeStrategy;

import java.util.HashMap;
import java.util.Map;

//import com.hong.qrpc.strategy.register.InjectStrategy;

/**
 * @Author HQT
 * @Date 2022/7/17 16:16
 */
public abstract class PropertiesStrategyFactory {
    private static Map<String, PropertiesStrategy> strategies = new HashMap<>();

    static {
        strategies.put(ClientConfig.QRPC_TRANSPORT_MANNER, new TransportClassStrategy());
        strategies.put(ClientConfig.QRPC_CLIENT_PORT, new PortStrategy());
        strategies.put(ClientConfig.QRPC_CODE_MANNER, new CodeClassStrategy());
        strategies.put(ClientConfig.QRPC_LOADBALANCE_MODE, new LoadBalanceModeStrategy());
        strategies.put(ClientConfig.QRPC_DISCOVER_SERVICE_ADDR, new DiscoverServiceAddrStrategy());
        strategies.put(ClientConfig.QRPC_REGISTER_CENTER_TYPE, new RegisterTypeStrategy());
        strategies.put(ClientConfig.QRPC_NUMBER_OF_TIMEOUT, new TimeoutStrategy());
        strategies.put(ClientConfig.QRPC_REQUEST_RETRIES, new RetryStrategy());
        strategies.put(ClientConfig.QRPC_PROTOCOL_TYPE, new ProtoTypeStrategy());
    }

    public static PropertiesStrategy getPropertiesStrategy(String propertiesName) {
        return strategies.get(propertiesName);
    }
}
